package util;

import java.util.List;

import model.Feed;

public class Tagging {

	@SuppressWarnings("deprecation")
	public static List<Feed> Tag(List<Feed> feedList)
	{
		for (Feed feed : feedList)
		{
			feed.setNote(feed.getNote().replaceAll("\\[(.*)\\]", "<a href='profileView?name=$1'>$1</a>"));
			
			feed.setNote(feed.getNote().replaceAll("\\|(.*)\\|", "<a href='tagView?name=$0'>$1</a>"));
			
			feed.setNote(feed.getNote().replaceAll("@Today", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 1) + "'>Today</a>"));
			feed.setNote(feed.getNote().replaceAll("@Tomarrow", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 2) + "'>Tomarrow</a>"));
			feed.setNote(feed.getNote().replaceAll("@Yesterday", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 0) + "'>Yesterday</a>"));
			feed.setNote(feed.getNote().replaceAll("@Morning", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 1) + "&h=9'>This Morning</a>"));
			feed.setNote(feed.getNote().replaceAll("@Noon", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 1) + "&h=12'>This Noon</a>"));
			feed.setNote(feed.getNote().replaceAll("@Afternoon", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 1) + "&h=18'>This Afternoon</a>"));
			feed.setNote(feed.getNote().replaceAll("@Night", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 1) + "&h=21'>This Night</a>"));
			feed.setNote(feed.getNote().replaceAll("(19|20)(\\d\\d)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])", "<a href='timeView?y=$1$2&m=$3&d=$4'>$0</a>"));
			feed.setNote(feed.getNote().replaceAll("(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?", "<a href='timeView?y=" + (feed.getCreated().getYear() + 1900) + "&m=" + (feed.getCreated().getMonth() + 1) + "&d=" + (feed.getCreated().getDay() + 1) + "&h=$1&mi=$4'>$0</a>"));
			
		}
		return feedList;
	}
	
}
